const webpack = require('webpack');

module.exports = {
    entry: __dirname + "/app/main.js", // 入口文件
    output: {
        path: __dirname + "/public", // 打包后文件存放位置
        filename: "bundle.js" // 打包后输出文件名
    },
    devtool: "eval-source-map",
    devServer: {
        contentBase: "./public", // 服务器加载的页面
        // historyBaseFallback: true, // 不跳转
        inline: true, // 实时刷新
        port: 8080, // 监听端口，默认
    },
    module: {
        rules: [
            {
                test: /(\.jsx|\.js)$/,
                use: {
                    loader: "babel-loader",
                    options: {
                        presets: ["env","react"]
                    }
                },
                exclude: /node_modules/
            },
            {
                test: /\.css$/,
                use: [
                    {
                        loader: "style-loader"
                    },
                    {
                        loader: "css-loader",
                        options: {
                            modules: true,
                            localIdentName: "[name]__[local]--[hash:base64:5]"
                        }
                    },
                    {
                        loader: "postcss-loader"
                    }
                ]
            }
        ]
    },
    plugins: [
        new webpack.BannerPlugin('版权所有，盗版必究')
    ]
};